package exercise.day06;

import java.util.Arrays;

public class Method {
    public static void main(String[] args) {
        sy();
        syHi("超级赛亚人");
        syHello("路飞", 88);
        double a1 = getNum();
        System.out.println(a1);
        int a = 5, b = 10;
        int c = plus(a, b);
        System.out.println("和："+c);
        int[] a2=testArray(10,50);
        System.out.println("长度："+a2.length);
        System.out.println("最后一个值："+a2[a2.length-1]);
        a2= Arrays.copyOf(a2,a2.length+1);

        int max=a2[0];
        for(int i=0;i<a2.length;i++){
            if(max<a2[i]){
                max=a2[i];
            }
            a2[a2.length-1]=max;
            System.out.print(a2[i]+" ");
        }
        System.out.println();

        System.out.println("最大值："+max);
    }

    //无参无返
    public static void sy() {
        System.out.println("大家好我是那个男人，就是那个个男人，你么懂得，就是那个");
    }

    //有一个参无返回值
    public static void syHi(String name) {
        System.out.println("大家好，我叫" + name + "，今年已经1000岁了");
    }

    //有两个参无返回值
    public static void syHello(String name, int age) {
        System.out.println("大家好，我叫" + name + "今年" + age + "岁了");
    }

    //无参有返回值方法
    public static double getNum() {
        return 888.8;
    }

    //两个参有返回值方法
    public static int plus(int a, int b) {
        int mun = a + b;
        return mun;
    }

    public static int[] testArray(int len, int max) {
        int[] arr = new int[len];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int) (Math.random() * (max + 1));
            System.out.print(arr[i]+" ");
        }
        System.out.println();
        return arr;
    }
}

